package com.sgx.learning.luban.homework.attributes;

import com.sgx.learning.luban.homework.attributes.ext.LocalVariable;
import com.sgx.learning.luban.homework.basictype.U2;
import com.sgx.learning.luban.homework.constantpool.ConstantPoolInfo;

import java.io.IOException;
import java.io.InputStream;

public class LocalVariableTable extends AttributeInfo {

    private short localVariableLength;
    private LocalVariable[] localVariables;
    @Override
    public void read(InputStream is, ConstantPoolInfo[] constantPoolInfos) throws IOException {
        this.localVariableLength = U2.read(is).getValue();
        if(this.localVariableLength > 0) {
            this.localVariables = new LocalVariable[localVariableLength];
            for (int i = 0; i < localVariableLength; i++) {
                LocalVariable temp = new LocalVariable();
                temp.read(is);
                localVariables[i] = temp;
            }
        }
    }
}
